<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('订单列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="post-form">
                <div class="select-list">
                    <ul>
                        <li>
                            订单编号：<input type="text" name="orderid"/>
                        </li>
                        <li>
                            支付状态：<select name="pay_state" >
                            <option value="">所有</option>
                            <option value="0">未付款</option>
                            <option value="1">已支付</option>
                            <option value="2">申请付款</option>
                            <option value="3">已退款</option>
                        </select>
                        </li>
                        <li>
                            订单状态：<select name="state" >
                            <option value="">所有</option>
                            <option value="0">未付款</option>
                            <option value="1">待收货</option>
                            <option value="2">已送达</option>
                            <option value="3">已完成</option>
                            <option value="3">已关闭</option>

                        </select>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
<!--            				<a class="btn btn-warning" onclick="$.table.exportExcel()">-->
<!--            		            <i class="fa fa-download"></i> 导出-->
<!--            		        </a>-->
        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var manageFlag = [[${@permission.hasPermi('system:admin:manage')}]];
    var removeFlag = [[${@permission.hasPermi('water:order:remove')}]];
    var datas = [[${@dict.getType('sys_normal_disable')}]];
    var prefix = ctx + "water";
    $(function() {

        var options = {
            url:  prefix+ "/orderList",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/exportOrder",
            modalName: "订单列表",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: '编号'
                },
                {
                    field: 'create_time',
                    title: '提交时间',
                },
                {
                    field: 'user_id',
                    title: '订单账号',

                },
                {
                    field: 'total_amount',
                    title: '金额',
                },
                {
                    field: 'pay_state',
                    title: '支付状态',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if(value == 1){
                            actions.push('<span style="color: darkseagreen">已付款</span>&nbsp;');
                        }else if (value == 0){
                            actions.push('<span style="color: lightskyblue">未付款</span>&nbsp;');
                        }else if (value==2){
                            actions.push('<span style="color:  #ff7fce">申请退款</span>&nbsp;');
                        }else if (value==4){
                            actions.push('<span style="color: orangered">已退款</span>&nbsp;');
                        }
                        return actions.join('');
                    }
                },
                {
                    field: 'state',
                    title: '订单状态',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if(value == 1){
                            actions.push('<span style="color: orangered">待收货</span>&nbsp;');
                        }else if (value == 0){
                            actions.push('<span style="color: lightskyblue">未付款</span>&nbsp;');
                        }else if (value==2){
                            actions.push('<span style="color: darkseagreen">已送达</span>&nbsp;');
                        }else if (value==3){
                            actions.push('<span style="color: darkseagreen">已完成</span>&nbsp;');
                        }else if (value==4){
                            actions.push('<span style="color: darkseagreen">已关闭</span>&nbsp;');
                        }
                        return actions.join('');
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];

                        console.log(row.id);
                        var id ="id"+row.id;
                        actions.push("<a class='btn btn-primary btn-xs " + manageFlag + "' href='javascript:void(0)' onclick='manage(\""+id+"\")'><i class='fa fa-key'></i>查看订单</a> ");
                        actions.push('<a class="btn btn-success btn-xs" href="#" onclick="$.operate.edit(\''+row.id+'\')"><i class="fa fa-edit"></i>订单发货</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id+'\')"><i class="fa fa-remove"></i>删除</a>&nbsp;');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });
    /* 订单详情 */
    function manage(id) {
        var id = id.split("id");
        console.log(id[0]+"------>"+id[1])
        var url = prefix + '/showOrder/' + id[1];
        //第一个参数是标签的名称
        $.modal.openTab("订单管理", url);
    }
    function  editOrder(id) {
        var url = prefix + '/editOrder/' + id;
        //第一个参数是标签的名称
        $.modal.openTab("订单编辑", url);
    }
</script>
<script type="text/javascript">

</script>
</body>
</html>